package com.aletto.general_store.ui.adapters;

import android.content.Context;
import android.graphics.Color;
import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.aletto.general_store.R;
import com.aletto.general_store.data.DataRepository;
import com.aletto.general_store.data.model.Goods;
import com.aletto.general_store.presenters.core.SimpleParamsTemplate;
import com.aletto.general_store.presenters.core.SimpleTemplate;
import com.aletto.general_store.ui.activities.GoodsDetailsActivity;
import com.aletto.general_store.utils.ToastUtils;
import com.aletto.general_store.utils.XHelper;
import com.aletto.general_store.utils.image.GlideApp;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.listener.OnItemLongClickListener;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.sisyphus.spinach.core.INetTask;
import com.sisyphus.spinach.network.presenters.NetSingleTask;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;

public class BrowserHistoryAdapter extends BaseQuickAdapter<Goods, BaseViewHolder> {

    public BrowserHistoryAdapter() {
        super(R.layout.item_browser_history);
    }

    @Override
    protected void convert(@NonNull BaseViewHolder holder, Goods goods) {
        holder.setText(R.id.tv_goods_price, XHelper.toPrice(goods.getPrice()))
                .setText(R.id.tv_price_unit, goods.getPriceUnit());

        // 加载图片
        List<String> goodsImg = goods.getGoodsImg();
        if (goodsImg != null && !goodsImg.isEmpty()) {
            ImageView ivGoodsCover = holder.getView(R.id.iv_goods_cover);
            GlideApp.with(ivGoodsCover)
                    .load(goodsImg.get(0))
                    .goodsGrid()
                    .into(ivGoodsCover);
        }
    }

}
